import { Service } from "cl-admin";
import BaseService from "@/service/base";
@Service("finance")
class Finance extends BaseService {
	// 财务每日老师业绩
	teacherdayachieve({ time, bra_id = [], ...args }) {
		let params = {
			begin_time: time[0] || "",
			end_time: time[1] || "",
			bra_id: bra_id.join(),
			...args
		};
		return this.$get("/teacherdayachieve", { params });
	}
	// 财务部门支付参数
	listdeptpay(params) {
		return this.$get("/listdeptpay", { params });
	}
	// 删除财务部门支付参数
	deldeptpay(params) {
		return this.$post("/deldeptpay", params);
	}
	// 添加财务部门支付参数
	adddeptpay(params) {
		return this.$post("/adddeptpay", params);
	}
	// 编辑财务部门支付参数
	editdeptpay(params) {
		return this.$post("/editdeptpay", params);
	}
	// 产出比-城市
	cityOutPutRate({ date = [], bra_id = [], size, ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join(),
			pagesize: size
		};
		if (date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/cityOutPutRate", { params }).then(res => {
			return {
				list: res.data,
				pagination: {
					...params,
					size,
					total: res.total
				}
			};
		});
	}
	// 产出比-售前
	preOutPutRate({ date = [], bra_id = [], size, ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join(),
			pagesize: size
		};
		if (date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/preOutPutRate", { params }).then(res => {
			return {
				list: res.data,
				pagination: {
					...params,
					size,
					total: res.total
				}
			};
		});
	}
	// 产出比-售中
	midOutPutRate({ date = [], bra_id = [], size, ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join(),
			pagesize: size
		};
		if (date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/midOutPutRate", { params }).then(res => {
			return {
				list: res.data,
				pagination: {
					...params,
					size,
					total: res.total
				}
			};
		});
	}
	// 产出比-门店-推广
	storeOutPutRate({ date = [], bra_id = [], size, ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join(),
			pagesize: size
		};
		if (date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/storeOutPutRate", { params }).then(res => {
			return {
				list: res.data,
				pagination: {
					...params,
					size,
					total: res.total
				}
			};
		});
	}
	// 店。日详情
	dayDetail({ date = [], bra_id = [], ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join()
		};
		if (date && date.length) {
			params.btime = date[0];
			params.etime = date[1];
		}
		return this.$get("/dayDetail", { params });
	}
	// 店。日统计
	dayStatistic({ date = [], bra_id = [], ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join()
		};
		if (date && date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/dayStatistic", { params });
	}
	// 财务总报表
	totalStatistic({ date = [], bra_id = [], city_id = [], ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join(),
			city_id: city_id.join(',')
		};
		if (date && date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/totalStatistic", { params });
	}

	refundReport({ date = [], ...args }) {
		let params = {
			...args,
		};
		if (date && date.length) {
			params.btime = date[0];
			params.etime = date[1];
		}
		return this.$get("/refundReport", { params });
	}

	shopReport({ date = [], bra_id = [], city_id = [], ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join(),
			city_id: city_id.join(',')
		};
		if (date && date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/shopReport", { params });
	}

	zoneReport({ date = [], bra_id = [], city_id = [], ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join(),
			city_id: city_id.join(',')
		};
		if (date && date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/zoneReport", { params });
	}

	// 日。店统计
	datestoredetail({ date = [], bra_id = [], size, ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join(),
			pagesize: size
		};
		if (date && date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/datestoredetail", { params });
	}
	// 店。日详情2
	storedaydetail({ date = [], bra_id = [], ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join()
		};
		if (date && date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/storedaydetail", { params });
	}
	// 售中数据统计(财务)
	midSalesStatistics({ date = [], bra_id = [], ...args }) {
		let params = {
			...args
			// bra_id: bra_id.join()
		};
		if (date && date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/midSalesStatistics", { params });
	}
	// 日。店统计
	preDetail({ date = [], size, ...args }) {
		let params = {
			...args,
			pagesize: size
		};
		if (date && date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/preDetail", { params });
	}

	// 定金报表
	orderStatement({ date, dept_ids = [], bra_id = [], ...args }) {
		let params = {
			...args,
			dept_id: dept_ids.join(),
			bra_id: bra_id.join()

		};
		if (date && date.length) {
			params.btime = date[0];
			params.etime = date[1];
		}
		return this.$get("/orderstatement", { params }).then(res => {
			return {
				list: res,
				pagination: {
					...params,
					total: res.length
				}
			};
		});
	}

	//老师报表
	teacherreport({ date = [],  ...args }) {
		let params = {
			...args
		};
		if (date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		};
		// if (dept_ids && dept_ids.length) {
		//     params.dept_id = last(dept_ids);
		// }
		return this.$get("/teacherReport", { params });
	}
}
export default Finance;
